/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.kallsonys.object;

import java.io.Serializable;
import java.math.BigDecimal;
import java.math.BigInteger;
import javax.persistence.Basic;
import javax.persistence.Cacheable;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.persistence.Transient;
import javax.validation.constraints.NotNull;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author alladiab
 */
@Entity
@Cacheable(false)
@Table(name = "ORDERITEM")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Orderitem.findAll", query = "SELECT o FROM Orderitem o"),
    @NamedQuery(name = "Orderitem.findByOrderitemid", query = "SELECT o FROM Orderitem o WHERE o.orderitemid = :orderitemid"),
    @NamedQuery(name = "Orderitem.findByProductid", query = "SELECT o FROM Orderitem o WHERE o.productid = :productid"),
    @NamedQuery(name = "Orderitem.findByItemprice", query = "SELECT o FROM Orderitem o WHERE o.itemprice = :itemprice"),
    @NamedQuery(name = "Orderitem.findByIdOrder", query = "SELECT o FROM Orderitem o WHERE o.orderid = :orderid"),
    @NamedQuery(name = "Orderitem.findByItemquantity", query = "SELECT o FROM Orderitem o WHERE o.itemquantity = :itemquantity")})
public class Orderitem implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @NotNull
    @Column(name = "ORDERITEMID")
    private Long orderitemid;
    @Basic(optional = false)
    @NotNull
    @Column(name = "PRODUCTID")
    private long productid;
    // @Max(value=?)  @Min(value=?)//if you know range of your decimal fields consider using these annotations to enforce field validation
    @Basic(optional = false)
    @NotNull
    @Column(name = "ITEMPRICE")
    private BigDecimal itemprice;
    @Basic(optional = false)
    @NotNull
    @Column(name = "ITEMQUANTITY")
    private BigInteger itemquantity;
    @JoinColumn(name = "ORDERID", referencedColumnName = "ORDERID")
    @ManyToOne(optional = false)
    private OrderOms orderid;
    
    @Transient
    private String productName;
    
    

    public String getProductName() {
        return productName;
    }

    public void setProductName(String productName) {
        this.productName = productName;
    }

    public Orderitem() {
    }

    public Orderitem(Long orderitemid) {
        this.orderitemid = orderitemid;
    }

    public Orderitem(Long orderitemid, long productid, BigDecimal itemprice, BigInteger itemquantity) {
        this.orderitemid = orderitemid;
        this.productid = productid;
        this.itemprice = itemprice;
        this.itemquantity = itemquantity;
    }

    public Long getOrderitemid() {
        return orderitemid;
    }

    public void setOrderitemid(Long orderitemid) {
        this.orderitemid = orderitemid;
    }

    public long getProductid() {
        return productid;
    }

    public void setProductid(long productid) {
        this.productid = productid;
    }

    public BigDecimal getItemprice() {
        return itemprice;
    }

    public void setItemprice(BigDecimal itemprice) {
        this.itemprice = itemprice;
    }

    public BigInteger getItemquantity() {
        return itemquantity;
    }

    public void setItemquantity(BigInteger itemquantity) {
        this.itemquantity = itemquantity;
    }

    public OrderOms getOrderid() {
        return orderid;
    }

    public void setOrderid(OrderOms orderid) {
        this.orderid = orderid;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (orderitemid != null ? orderitemid.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Orderitem)) {
            return false;
        }
        Orderitem other = (Orderitem) object;
        if ((this.orderitemid == null && other.orderitemid != null) || (this.orderitemid != null && !this.orderitemid.equals(other.orderitemid))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.kallsonys.object.Orderitem[ orderitemid=" + orderitemid + " ]";
    }
    
}
